package com.zmyuan.demo.netty.protobuf;

import com.google.protobuf.InvalidProtocolBufferException;

/**
 * Created by zhudebin on 2017/2/14.
 */
public class TestProtobuf {

    public static void main(String[] args) {
        MsgProtobuf.Person
                person = MsgProtobuf.Person.newBuilder().setId(1).setName("hello").setEmail("hello@qq.com").build();

        byte[] bytes = person.toByteArray();

        try {
            MsgProtobuf.Person p = MsgProtobuf.Person.parseFrom(bytes);
            System.out.println(p.getId());
            System.out.println(p.getEmail());
            System.out.println(p.getName());
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }
    }
}
